'use strict';
const db = uniCloud.database()
exports.main = async (event, context) => {
	let apiUrl = 'https://v2.alapi.cn/api/eventHistory'
	let date = new Date();
	let month = date.getMonth() + 1;
	let strDate = date.getDate();
	const {
		data
	} = await uniCloud.httpclient.request(apiUrl, {
		method: 'GET',
		data: {
			month:month,
			day:strDate,
			page: "1",
			token: "K8NVh0xvERNNSX1l"
		},
		contentType: 'json',
		dataType: 'json'
	})
	if (data.code === 200) {
		let res = await db.collection('list_day').add({
			datanews: data.data,
			date:+new Date()
		})
		return res
	}
};
